﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Warehouse.DataAccess
{
    public partial class AssetAccount : CustomeEntity<AssetAccount>
    {
        public static AssetAccount Empty = new AssetAccount()
        {
            ID = 0,
            Name = string.Empty,
            AccountType = AssetAccountType.Unkown
        };

        public AssetAccountType AccountType
        {
            get { return (AssetAccountType)this.Type; }
            set { this.Type = (int)value; }
        }

        protected override System.Linq.Expressions.Expression<Func<AssetAccount, bool>> GetPredicate()
        {
            return (p => p.ID == this.ID);
        }

        #region Public Static Methods

        public static AssetAccount GetAssetAccount(int ID)
        {
            using (WarehouseClassesDataContext ctx = new WarehouseClassesDataContext())
            {
                return (from t in ctx.AssetAccount where t.ID == ID select t).SingleOrDefault();
            }
        }

        public static AssetAccount[] GetAssetAccounts()
        {
            using (WarehouseClassesDataContext ctx = new WarehouseClassesDataContext())
            {
                return ctx.AssetAccount.ToArray();
            }
        }

        #endregion
    }

    public enum AssetAccountType
    {
        Unkown = 0,
        Cash = 1,
        Bank = 2
    }
}
